package com.bilin.coin.network.paser;

import com.bilin.coin.network.RequestUtils;
import com.bilin.coin.network.bean.ModelBean2;
import com.google.gson.reflect.TypeToken;

import java.util.List;


public class PaserUtils {

    //解析data是object的情况
    public <T> ModelBean2<T> fromJsonObject(String json) {
        //Type type = new ParameterizedTypeImpl(ModelBean2.class, new Class[]{clazz});
        return RequestUtils.getGson().fromJson(json, new TypeToken<ModelBean2<T>>(){}.getType());
    }

    //解析data是array的情况
    public <T> ModelBean2<List<T>> fromJsonArray(String json) {
        return RequestUtils.getGson().fromJson(json, new TypeToken<ModelBean2<List<T>>>(){}.getType());
    }
}
